﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Media;

namespace Report
{
    public static class ReportCommon
    {
        static ReportCommon()
        {
            CultureInfo currentCultureInfo = CultureInfo.CurrentCulture;
            GetLan = Application.LoadComponent(
                new Uri(@"Languages\" + currentCultureInfo.Name + ".xaml", UriKind.Relative)) as ResourceDictionary;

        }

        public static ResourceDictionary GetLan { get; }

        public static T FindVisualParent<T>(DependencyObject obj) where T : class
        {
            while (obj != null)
            {
                if (obj is T)
                    return obj as T;

                obj = VisualTreeHelper.GetParent(obj);
            }

            return null;
        }
    }
}
